From: Juri Linkov Date: Thu, 1 Jul 2004 09:58:44 +0000 (+0000) Subject: (query-replace-interactive): Change type from boolean X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1~1^2~21772 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=e05a9f3ea2f9151a3cf54cf7ea045839c2dac409;p=emacs.git (query-replace-interactive): Change type from boolean to choice. Add value `initial'. (query-replace-read-args): Handle value `initial' of query-replace-interactive. --- diff --git a/lisp/replace.el b/lisp/replace.el index c2305cdecc6..cac4470c9cd 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -38,8 +38,12 @@ (defcustom query-replace-interactive nil "Non-nil means `query-replace' uses the last search string. -That becomes the \"string to replace\"." - :type 'boolean +That becomes the \"string to replace\". +If value is `initial', the last search string is inserted into +the minibuffer as an initial value for \"string to replace\"." + :type '(choice (const :tag "Off" nil) + (const :tag "Initial content" initial) + (other :tag "Use default value" t)) :group 'matching) (defcustom query-replace-from-history-variable 'query-replace-history @@ -70,16 +74,20 @@ strings or patterns." (unless noerror (barf-if-buffer-read-only)) (let (from to) - (if query-replace-interactive - (setq from (car (if regexp-flag regexp-search-ring search-ring))) + (if (and query-replace-interactive + (not (eq query-replace-interactive 'initial))) + (setq from (car (if regexp-flag regexp-search-ring search-ring))) ;; The save-excursion here is in case the user marks and copies ;; a region in order to specify the minibuffer input. ;; That should not clobber the region for the query-replace itself. (save-excursion - (setq from (read-from-minibuffer (format "%s: " string) - nil nil nil - query-replace-from-history-variable - nil t))) + (setq from (read-from-minibuffer + (format "%s: " string) + (if (eq query-replace-interactive 'initial) + (car (if regexp-flag regexp-search-ring search-ring))) + nil nil + query-replace-from-history-variable + nil t))) ;; Warn if user types \n or \t, but don't reject the input. (and regexp-flag (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from) @@ -92,9 +100,10 @@ strings or patterns." (sit-for 2)))) (save-excursion - (setq to (read-from-minibuffer (format "%s %s with: " string from) - nil nil nil - query-replace-to-history-variable from t))) + (setq to (read-from-minibuffer + (format "%s %s with: " string from) + nil nil nil + query-replace-to-history-variable from t))) (when (and regexp-flag (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to)) (let (pos list char)